package com.six.controller;

import com.six.pojo.CustomerCapital;
import com.six.pojo.CustomerContacts;
import com.six.result.Result;
import com.six.result.ResultUtils;
import com.six.service.CustomerCapitalService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * @author luolu
 * @create 2022/3/7 21:56
 */
@Controller
@ResponseBody
@RequestMapping("/customerCapital")
@Api(tags = "客户财务情况接口")
public class CustomerCapitalController {
    @Autowired
    private CustomerCapitalService customerCapitalService;
    /**
     * 客户财务情况
     * @param customerCapital
     * @return
     */
    @ApiOperation(value = "新增客户财务情况数据" ,notes = "新增客户财务情况数据")
    @ApiResponses({
            @ApiResponse(code = 400, message = "请求参数没填好"),
            @ApiResponse(code = 404, message = "请求路径没有或页面跳转路径不对"),
            @ApiResponse(code = 200, message = "请求成功！")
    })
    @RequestMapping(value = "/add",method = RequestMethod.POST)
    //RequestBody 规定为json格式的数据
    public Result add(@RequestBody @ApiParam(name = "CustomerCapital", value = "新增的客户财务情况字段") CustomerCapital customerCapital){
        customerCapitalService.save(customerCapital);
        return ResultUtils.buildSuccess();
    }


    /**
     * 根据id删除客户财务情况
     * @param id
     * @return
     */
    @ApiOperation(value = "根据id删除客户财务情况" ,notes = "根据id删除客户财务情况")
    @ApiResponses({
            @ApiResponse(code = 400, message = "请求参数没填好"),
            @ApiResponse(code = 404, message = "请求路径没有或页面跳转路径不对"),
            @ApiResponse(code = 200, message = "请求成功！")
    })
    @RequestMapping(value = "/deleteById",method = RequestMethod.GET)
    public Result delete(@RequestParam @ApiParam(name = "id", value = "客户财务情况的id")Long id){
        customerCapitalService.removeById(id);
        return ResultUtils.buildSuccess();
    }
}
